package com.isoft.demo.dao;

import com.isoft.demo.entity.Transport;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface FindTransferSysDao {

    @Select("SELECT tid,oidt,f.faddress fidt,tdate,v.vnumber vidt,e.ename eidt,sdate FROM transport t " +
            "JOIN vehicle v ON t.vidt=v.vid " +
            "JOIN employee e ON t.eidt=e.eid " +
            "JOIN filial f ON t.fidt=f.fid")
    List<Transport> findTranSys();

    @Select("SELECT tid,oidt,f.faddress fidt,tdate,v.vnumber vidt,e.ename eidt,sdate FROM transport t " +
            "JOIN vehicle v ON t.vidt=v.vid " +
            "JOIN employee e ON t.eidt=e.eid " +
            "JOIN filial f ON t.fidt=f.fid " +
            "WHERE tid=#{tid}")
    List<Transport> findById(int tid);

    @Select("SELECT tid,oidt,f.faddress fidt,tdate,v.vnumber vidt,e.ename eidt,sdate FROM transport t " +
            "JOIN vehicle v ON t.vidt=v.vid " +
            "JOIN employee e ON t.eidt=e.eid " +
            "JOIN filial f ON t.fidt=f.fid " +
            "WHERE sdate BETWEEN #{sdate} AND #{edate}")
    List<Transport> findByDate(String sdate,String edate);

    @Select("SELECT tid,oidt,f.faddress fidt,tdate,v.vnumber vidt,e.ename eidt,sdate FROM transport t " +
            "JOIN vehicle v ON t.vidt=v.vid " +
            "JOIN employee e ON t.eidt=e.eid " +
            "JOIN filial f ON t.fidt=f.fid " +
            "WHERE tid=#{tid} AND sdate BETWEEN #{sdate} AND #{edate}")
    List<Transport> findBy(int tid,String sdate,String edate);

    @Insert("insert into transport(oidt,vidt,eidt,fidt,tdate)values(#{oid},#{vnumber},#{ename},#{faddress},#{tdate})")
    int addTransport(Transport transport);
}
